package com.google.code.netbuilder.dal.entities;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

/**
 * Equipment template entity 
 *(Table: equipment type)
 * Used for xml-template loading for equipment creation
 * @author Sergey Kozlov
 *
 */
@Entity
@Table(name="equipment_type")
@SequenceGenerator(sequenceName = "equipment_template_seq", name = "equipment_template_seq", initialValue = 1, allocationSize = 100)
public class EquipmentTemplate extends ManagedObject{

	private static final long serialVersionUID = -98345278187667886L;
	
    @Column(name = "xml_str")
	private String xml;
	
	public String getXml() {
		return xml;
	}

	public void setXml(String xml) {
		this.xml = xml;
	}

	@Override
	public boolean equals(Object ob){
	        if(ob == null)
	        {
	            return false;
	        }
	        if(!(ob instanceof EquipmentTemplate))
	        {
	            return false;
	        }
	        EquipmentTemplate castedOb = (EquipmentTemplate) ob;
	        return super.equals(ob) && 
	               (this.getName() != null ? this.getName().equals(castedOb.getName()) : castedOb.getName() == null) &&
	               (xml != null ? castedOb.getXml().equals(xml) : castedOb.getXml() == null);
	    }

	    @Override
	    public String toString() {
	        return "EquipmentTemplate{" + super.toString() + ", name= " + getName() + ", xml= " + xml + '}';
	    }
}
